/**
 * 
 */
package ro.dta.idbi.model.dynamicpattern;

/**
 * Container for a pair of integers
 * 
 * @author Tudor Dobrila
 * 
 */
class DoublePair {
	private double x;
	private double y;

	/**
	 * Pair of integers class constructor
	 */
	public DoublePair() {
		this.x = 0;
		this.y = 0;
	}

	/**
	 * Pair of integers class constructor
	 * 
	 * @param x
	 *            First value
	 * @param y
	 *            Second value
	 */
	public DoublePair(double x, double y) {
		this.x = x;
		this.y = y;
	}

	/**
	 * @param x
	 *            Set the first value stored in this pair
	 */
	public void setX(double x) {
		this.x = x;
	}

	/**
	 * @return First value in the pair
	 */
	public double getX() {
		return x;
	}

	/**
	 * @param y
	 *            Set the second value in the pair
	 */
	public void setY(double y) {
		this.y = y;
	}

	/**
	 * @return The second value in the pair
	 */
	public double getY() {
		return y;
	}

	@Override
	public int hashCode() {
		StringBuilder builder = new StringBuilder();
		builder.append(x).append(y);
		return builder.toString().hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof DoublePair) {
			DoublePair doublePair = (DoublePair) obj;
			return x == doublePair.getX() && y == doublePair.getY();
		}

		return false;
	}

	@Override
	public String toString() {
		return x + " " + y;
	}
}
